# -*- coding: utf-8 -*-
# @Time    : 2022/1/7 14:41
# @Author  : 徐翊宸
# @Email   : xyc@163.com
# @File    : page_login.py
# @Software: PyCharm
from selenium.webdriver.common.by import By
from pages.base_page import BasePage

class LoginPage(BasePage):

    username_locator = (By.NAME, "name")
    password_locator = (By.NAME, "password")
    submit_locator = (By.NAME, "submit")
    duanyan_locator = (By.CSS_SELECTOR, "body > div.container > div.alert.alert-success")



    def username_input(self, username):
        self.driver.find_element(*self.username_locator).send_keys(username)

    def password_input(self, password):
        self.driver.find_element(*self.password_locator).send_keys(password)

    def submit_click(self):
        self.driver.find_element(*self.submit_locator).click()

    def assert_duanyan(self):
        return  self.driver.find_element(*self.duanyan_locator).text


    def open(self):
        self.driver.get(self.url+"/crm")

    def denglu(self,username,passwd):
        self.open()
        self.username_input(username)
        self.password_input(passwd)
        self.submit_click()

